
SocialAdd = function( vars )	{

	Object.extend( obj = $$( '.SocialAdd' ).pop(), SocialAdd.proto );
	
	obj.trigger	 	= obj.select( ".add" );
	obj.mod			= obj.select( ".mod" ).pop();
	obj.vars		= vars;
	
	return obj;
}



SocialAdd.proto =	{

	showOrHide		: function() {
	
		this.mod.hide();
	
		this.trigger.each( function( el, i ) {
			el.observe( 'click', function() {
			
				if( this.vars.personal ) {
					this.checkUser();
				}
				if( el.next().select( 'h1' )) {
					el.next().select( 'h1' ).each( function( node ) { node.hide()});
				}	
				if( el.next().visible()) {
					el.next().hide().removeClassName( 'open' );
					el.up().removeClassName( 'open' );
				}	
				else {
					el.next().addClassName( 'open' ).setStyle({ 'padding': 0, 'border': 0, 'background': 'transparent', 'margin': 0, '-webkit-box-shadow': 'none', 'box-shadow': 'none', 'width': '100%' }).show();
					el.up().addClassName( 'open' );
				}
			}.bind( this ));
		}.bind( this ));
	},
	
	
	checkUser		: function() {
	
		xhttp.send( 
			'/xhttp.mod', 
			{ mod: "social.add", action: "check_user", vars: { vars: this.vars }}, 
			this.responder.bind( this )
		);
	},
	
	
	responder	: function( response ) {
	
		var set = response.responseText.evalJSON();
		var mod = new Element( 'div', { 'class': 'mod TextBasic login' }).setStyle({ 'padding': 0, 'border': 0, 'background': 'transparent', 'margin': 0, '-webkit-box-shadow': 'none', 'box-shadow': 'none', 'width': '100%' }).update( set.mod );
		
		//console.log( mod );
		
		if( !init.userid && this.vars.personal ) {
			this.mod.hide()
			this.mod.wrap().update( mod ).show();
		}
	}
}
